//
//  WDBaseNavController.swift
//  SINAWeiBo
//
//  Created by wangwei on 2016/11/12.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class WDBaseNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        let count = childViewControllers.count
        
        if count > 0 {
            
            //第一个,是隐藏TabBar 
            
            viewController.hidesBottomBarWhenPushed = true
            
            //第二个
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(back))
        }
        
        super.pushViewController(viewController, animated: animated)
        
        
    }
    
    //返回函数
    func back() {
    
        popViewController(animated: true)
    }
    

}
